<?php
/**
 * @apiVersion 1.0.0
 * @api {POST} /wechat/User/getUserInfo 004获取用户信息接口OK
 * @apiDescription 获取用户信息接口
 * @apiGroup Pub
 * @apiPermission 公众号

 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{
    "code": 1,
    "msg": "登录成功",
    "data": {
        "userID": 237,  //用户id
        "photo": null,  //头像
        "mobile": "15573179664",  //手机号
        "nickname": null,  //昵称
        "sex": 0,  //性别：
        "trueName": "张三",  //真实姓名
        "card": "273273723723",  //身份证号码
        "updataTime": 1620157828,
        "addTime": 1620157741,  //注册时间
        "status": 1,      //状态： 1正常 0禁用
        "serialNumber": null,
        "appType": null,
        "mobileType": null,
        "password": null,
        "payPassword": null,
        "agent": null,
        "clientIP": "3740760482",
        "location": null,
        "judge": 0,
        "version": null,
        "latitude": null,
        "longitude": null,
        "apliayUsername": null, //支付宝账号
        "apliayPassword": null, //支付宝密码
        "apliayPayPassword": null,  //支付宝支付密码
        "wechatUsername": null, //微信账号
        "wechatPassword": null, //微信密码
        "wechatPayPassword": null,  //微信支付密码
        "depositUsername": null,    //提现账号
        "depositType": null,    //提现类型： 1支付宝 2微信
        "platformID": 0,    //平台id
        "statusCheck": -1,
        "xrkCode": null,    //葵码
        "checkTime": null,
        "checkManger": null,
        "cMobile": "",
        "depositRealname": "",
        "openID": null, //微信openid
        "unionID": null,    //开发平台id
        "loginTimes": 3,
        "lastLoginTime": 1620157828
    }
}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */



/**
 * @apiVersion 1.0.0
 * @api {POST} /wechat/User/updateUser 005微信信息更新OK
 * @apiDescription 微信信息更新
 * @apiGroup Wx
 * @apiPermission 公众号
 * @apiParam {string} openid 微信openid
 * @apiParam {string} nickname 微信昵称
 * @apiParam {string} headUrl 微信头像
 * @apiParam {string} unionid 开发平台ID
 * @apiParamExample {json} 请求示例:
 * {
 *      "openid": "7724724hfhfhdf3636466666",
 *      "nickname": "用户昵称",
 *      "headUrl": "http://www.n.com/1.png",
 *      "unionid": hdfhdhfhdfe,
 * }
 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{

}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */


/**
 * @apiVersion 1.0.0
 * @api {POST} /wechat/User/edit 008用户信息收集接口OK
 * @apiDescription 用户资料完善接口
 * @apiGroup Wx
 * @apiPermission 公众号
 * @apiParam {string} mobile 用户手机号码
 * @apiParam {int} sex 性别: 0未知 1男 2女
 * @apiParam {string} nickname 昵称
 * @apiParam {string} trueName 真实姓名
 * @apiParam {string} card 身份证号码
 * @apiParam {string} headUrl 微信头像
 * @apiParam {string} apliayUsername 支付宝账号
 * @apiParam {string} apliayPassword 支付宝登录密码
 * @apiParam {string} apliayPayPassword 支付宝支付密码
 * @apiParam {string} wechatUsername 微信账号
 * @apiParam {string} wechatPassword 微信登录密码
 * @apiParam {string} wechatPayPassword 微信支付密码
 * @apiParam {string} depositUsername 收款账号
 * @apiParam {string} depositType 收款类型： 1支付宝 2微信
 * @apiParam {string} cMobile 常用手机号
 * @apiParam {string} depositRealname 收款真实姓名
 * @apiParam {string} platformID 平台ID
 * @apiParamExample {json} 请求示例:
 * {
 *      "nickname": "用户昵称",
 *      "headUrl": "http://www.n.com/1.png",
 *      "unionid": hdfhdhfhdfe,
 *       "....": ...
 * }
 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{

}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */



/**
 * @apiVersion 1.0.0
 * @api {POST} /wechat/User/platformList 009获取平台列表OK
 * @apiDescription 获取平台列表
 * @apiGroup Wx
 * @apiPermission 公众号

 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{
    'list':{
        'name': '比特王国',
        'id': 100
    }
}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */

/**
 * @apiVersion 1.0.0
 * @api {GET} /wechat/User/getGroupMoneylist 2001佣金明细列表OK
 * @apiDescription 佣金明细列表
 * @apiGroup User
 * @apiPermission 公众号
 * @apiParam {int} year 年份
 * @apiParam {int} month 月份
 * @apiParam {int} turnover 类型：-1支出 1收入
 * @apiParam {int} page 页码
 * @apiParam {int} size 每页数量
 * @apiParamExample {json} 请求示例:
 * {
 *      "year": 2021,
 *      "month": 03,
 *      "turnover": 1,
 *      "page": 1,
 *      "size": 10,
 * }

 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{
    "code": 1,
    "msg": "成功",
    "data": {
        "withdrawMoney": 200.88,    //总的提现金额
        "totalMoney": 10002.22,    //总收入
        "ygMoney": 10002.22,    //预估收益
        "money": 10002.22,    //当前余额
        "count": 10,    //记录条数
        "list": [
        {
            "logid": 417,
            "userID": 338,
            "orderID": 193,
            "ordertype" //类型：1奖励 4提现
            "amount": "5.00",    金额
            "turnover": -1,
            "content": "波比艾斯获得佣金 5.00元 ",   //备注
            "addtime": "今天 14:26",
            "update_time": "2019-04-05 14:27:51",
            "balance": "0.99",
    }
    ],
    }
}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */

/**
 * @apiVersion 1.0.0
 * @api {POST} /wechat/User/tixian 2002提现申请ok
 * @apiDescription 提现申请
 * @apiGroup User
 * @apiPermission 公众号
 * @apiParam {float} amount 提现金额
 * @apiParamExample {json} 请求示例:
 * {
 *      "amount": 2021,
 * }

 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{
    "code": 1,
    "msg": "提现申请成功",
    "data": {
        "userID": 238,  //用户id
        "money": 100,   //提现金额
        "tradeNo": "",  //微信单号
        "status": 0,    //提现状态   0处理中    1已完成     2失败
        "content": "用户提现",  //备注
        "codeRed": "19497855",  //红包码
        "depositID": "24",  //提现ID
        "qrcodeUrl": "http://collectapi.jujingame.com/wechat/weixin/bind?preurl=http%3A%2F%2Fwdqq.jujingame.com%2F%23%2Fpages%2Fwxsq%2Fwxsq&type=wurl"  //二维码链接
    }
}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */


/**
 * @apiVersion 1.0.0
 * @api {POST} /wechat/User/getRedPacket 2003领取红包接口ok
 * @apiDescription 领取红包接口ok
 * @apiGroup User
 * @apiPermission 公众号
 * @apiParam {float} openid 微信openid
 * @apiParam {string} mobile 手机号
 * @apiParam {int} cashID 提现id
 * @apiParam {floag} money 金额
 * @apiParamExample {json} 请求示例:
 * {
 *      "openid": 'rrhrhewdfgdgfdgf23424',
 *      "mobile": '15574778989',
 *      "cashID": '100',
 *      "money": 100.29,
 * }

 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{
"code": 1,
"msg": "提现成功"
}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */


/**
 * @apiVersion 1.0.0
 * @api {POST} /wechat/User/indexData 3001首页接口ok
 * @apiDescription 首页接口
 * @apiGroup INDEX
 * @apiPermission 公众号
 * @apiParam {string} keyword 搜索词
 *  * @apiParam {int} page 页码
 * @apiParam {int} size 每页数量
 * @apiParamExample {json} 请求示例:
 * {
 *      "keyword": '签到任务',
 *      "page": '1',
 *      "size": '10',
 * }

 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{
    "code": 1,
    "msg": "操作成功",
    "data": {
        "task_refer": 推荐任务

                "taskID": 1,
                "title": "一秒助力",
                "logo": "1.png",
                "rewardName": "按要求进行操作",
                "rewardMoney": 5,
                "label": "'财神到','超赞'",
                "addTime": "2018-07-16 10:22:37"

        ,
        "task_list": [  最新任务列表
            {
                "taskID": 1,
                "title": "一秒助力",
                "logo": "1.png",
                "rewardName": "按要求进行操作",
                "rewardMoney": 5,
                "label": "'财神到','超赞'",
                "addTime": "2018-07-16 10:22:37"
            }
        ],
        'count' => 100, 任务条数
        "banner": [     //轮播图列表
            {
                "bannerID": 5,
                "title": "十元疯抢1",
                "thumb": "https://laike-1257904924.cos-website.ap-shanghai.myqcloud.com/2019-06-18/13dbde4ab6e9f55e803aae958b87c90a.jpg",
                "link": "2"
            },
            {
                "bannerID": 182,
                "title": "商超轮播图",
                "thumb": "https://laike-1257904924.cos-website.ap-shanghai.myqcloud.com/2019-12-21/bac567431aef2e5fb4be5776399fc7dc.png",
                "link": "www.baidu.com"
            },
            {
                "bannerID": 183,
                "title": "2",
                "thumb": "https://laike-1257904924.cos-website.ap-shanghai.myqcloud.com/2019-12-21/d04dccde9777d87a83ad78d374192d17.jpg",
                "link": "649"
            }
        ]
    }
}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */

/**
 * @apiVersion 1.0.0
 * @api {POST} /wechat/User/getUserInit 2004用户协议和用户隐私接口0k
 * @apiDescription 用户协议和用户隐私接口
 * @apiGroup User
 * @apiPermission 公众号


 * @apiSuccess  {Int} code 状态
 * @apiSuccess  {Object} data 元数据
 * @apiSuccess  {String} msg 错误说明
 * @apiSuccessExample {json} 响应示例:
{
    "code": 1,
    "msg": "操作成功",
    "data": {
        "userText": "<span>用户协议</span>",
        "ysText": "<span>用户隐私</span>",
    }
}

 * //操作未成功提示信息
 * {
 *      "code":0,
 *      "msg" :"错误说明"
 * }
 */



namespace app\wechat\controller;


use app\model\FreshAdminAuthGroupAccess;
use app\model\FreshAdminUser;

use app\model\FreshAdminUserData;
use app\model\UserDeposit;
use app\model\UserMoneyLog;
use app\util\ReturnCode;
use app\util\Tools;
use Pament\wxPament;
use think\Db;
use think\Exception;
use think\Model;

class User extends Base {


    /**
     * 新增用户
     */
    public function getUserInfo() {
        $postData = $this->request->post();

        $user = Db::name('user')->where('userID', $this->userInfo['userID'])->find();
        $platform = Db::name('platform')->where('id', $user['platformID'])->find();
        $user['platformText'] = $platform['name'];
        $num = Db::name('user_msg')
            ->where(['isRead' => 2, 'userID' => $this->userInfo['userID']])
            ->count();
        $user['msg_num'] = $num?$num:0;
        return $this->buildSuccess($user, '操作成功');
    }

    public function updateUser(){
        $postData = $this->request->post();
        if(!isset($postData['openid'])) return $this->buildFailed(ReturnCode::INVALID,'微信openid不能为空');
        if(!isset($postData['nickname'])) return $this->buildFailed(ReturnCode::INVALID,'微信昵称不能为空');
        if(!isset($postData['headUrl'])) return $this->buildFailed(ReturnCode::INVALID,'微信头像不能为空');
        $user_wechat = Db::name('user')->where(['openID' =>$postData['openid']])->find();
        if(!isset($user_wechat['userID'])){  //未插入微信信息,绑定微信
            Db::name('user')->where(['userID' => $this->userInfo['userID']])->update([
                'openID' => $postData['openid'],
                'nickname' => $postData['nickname'],
                'photo' => $postData['headUrl'],
                'unionID' => isset($postData['unionid'])?$postData['unionid']:'']);
            return  $this->buildSuccess([], '操作成功');
        }else{ //已插入微信信息
            if($user_wechat['userID'] != $this->userInfo['userID']){  //自动解绑
                Db::name('user')->where(['userID' => $user_wechat['userID']])->update(
                    [
                        'openID' => '',
                        'nickname' => '',
                        'photo' => '',
                        'unionID' => ''
                    ]);
                Db::name('user')->where(['userID' => $this->userInfo['userID']])->update(
                    [
                        'openID' => $postData['openid'],
                        'nickname' => $postData['nickname'],
                        'photo' => $postData['headUrl'],
                        'unionID' => isset($postData['unionid'])?$postData['unionid']:''
                    ]);
            }
            return  $this->buildSuccess([], '操作成功');
        }
    }


    public function edit(){


        $postData = $this->request->post();
        $user = \app\model\User::get(['userID' => $this->userInfo['userID']]);
        if(!isset($user['userID'])) return $this->buildFailed(ReturnCode::INVALID, '用户不存在');

        if(isset($postData['card'])){
            $result = \app\model\User::get(['card' => $postData['card']]);
            if(isset($result['userID']) && $result['userID'] != $user['userID']) return $this->buildFailed(ReturnCode::INVALID, '该身份证号码已注册');
        }

        if(isset($postData['apliayUsername'])){
            $result = \app\model\User::get(['apliayUsername' => $postData['apliayUsername']]);
            if(isset($result['userID']) && $result['userID'] != $user['userID']) return $this->buildFailed(ReturnCode::INVALID, '该支付宝账号已注册');
        }

        if(isset($postData['wechatUsername'])){
            $result = \app\model\User::get(['wechatUsername' => $postData['wechatUsername']]);
            if(isset($result['userID']) && $result['userID'] != $user['userID']) return $this->buildFailed(ReturnCode::INVALID, '该微信账号已注册');
        }


        if(isset($postData['xrkCode'])){
            $result = \app\model\User::get(['xrkCode' => $postData['xrkCode']]);
            if(isset($result['userID']) && $result['userID'] != $user['userID']) return $this->buildFailed(ReturnCode::INVALID, '该葵码已绑定');
        }
        $model = new \app\model\User();
        $user = $model->where('userID', $user['userID'])->find();
        if($user['modifyTimes']<=0)    return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '修改资料次数已用完');
        unset($postData['addTime']);
        unset($postData['checkTime']);
        $postData['updataTime'] = time();
        $postData['statusCheck'] = -1;
        $res = $model->strict(false)->where('userID', $user['userID'])->update($postData);
        if ($res === false) {
            $model->strict(false)->where('userID', $user['userID'])->setDec('modifyTimes', 1);
            return $this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
        } else {
            return $this->buildSuccess([]);
        }

    }

    public function platformList(){

        $list = Db::name('platform')->select();
        return $this->buildSuccess(['list' => $list]);
    }


    //获取余额流水列表
    public function getGroupMoneylist() {
        $param = $this->request->get();
        $page = $this->request->get('page', 1);//当前页数
        $size = $this->request->get('size', config('apiAdmin.ADMIN_LIST_DEFAULT'));//每页显示数量
        $where['userID'] = $this->userInfo['userID'];
        if(isset($param['year'])&& isset($param['month'])){
            $timestamp = strtotime( $param['year'].'-'.$param['month'] );
            $start_time = date( 'Y-m-1 00:00:00', $timestamp );
            $mdays = date( 't', $timestamp );
            $end_time = date( 'Y-m-' . $mdays . ' 23:59:59', $timestamp );
            $where['addtime'] = [
                ['>=', strtotime($start_time)],
                ['<=', strtotime($end_time)],
            ];
        }
        if(!empty($this->appData['turnover'])){
            $where['turnover'] = $param['turnover'];
        }
        $model = new UserMoneyLog();
        $list = $model
            ->where($where)
            ->limit(($page-1)*$size, $size)
            ->order('addTime desc')
            ->select();
        if ($list){
            $list->append(['OrdertypeText']);
        }

        $user = \app\model\User::get($this->userInfo['userID']);

        $total = $model::where($where)->count();

        $result = Db::name('user_award')->where([
            'userID' => $this->userInfo['userID']
        ])->sum('money');

        return Tools::buildReturn(1,'成功',
            ['money' => $user['money'], 'ygMoney' => Tools::bcCalculate($result, 100, '/'), 'totalMoney' => $user['totalMoney'], 'list' => $list, 'withdrawMoney' => $user['withdrawMoney'], 'count' => $total]);
    }

    public function tixian(){
        return Tools::buildReturn(ReturnCode::INVALID,'暂不开放');
        $param = $this->request->post();
        if(!is_numeric($param['amount'])||strpos($param['amount'],".")!==false){
            return Tools::buildReturn(ReturnCode::INVALID,'提现金额必须是整数');
        }
        $amount = intval($param['amount']);
        if($amount<1)  return Tools::buildReturn(ReturnCode::INVALID,'提现金额必须大于5');
        if($amount>1000)  return Tools::buildReturn(ReturnCode::INVALID,'提现单笔不超过1000元');
        $H = date('H');
        /*if($H<9 || $H>=17){
            return Tools::buildReturn(ReturnCode::INVALID,'只允许9:00~17:00时间段提现');
        }*/
        $userID = $this->userInfo['userID'];
        $userInfo = \app\model\User::get($userID);
        if($userInfo['status'] != 1){
            return Tools::buildReturn(ReturnCode::INVALID,'用户已被冻结');
        }


        $DepositModel = new \app\model\UserDeposit();
        $add = [
            'userID' => $userID,
            'money' => $amount,
            'tradeNo' => '',
            'status' => 0,
            'content' => '用户提现',
            'codeRed' => Tools::getCodeRed()
        ];
        $result = $DepositModel->create($add);
        $add['depositID'] = $result->depositID;
        $preurl = urlencode("http://wdqq.jujingame.com/#/pages/Withdrawal/collection?depositID={$result->depositID}&mobile={$userInfo['mobile']}&money={$add['money']}");
        $add['qrcodeUrl'] = 'http://collectapi.jujingame.com/wechat/weixin/bind?preurl='.$preurl.'&type=wurl';
        $QRcode = getQrcode($add['qrcodeUrl'],'',1);
        $add['qrcodeUrl'] = $QRcode;
        return Tools::buildReturn(ReturnCode::SUCCESS,'提现申请成功', $add);


        $wxPament = new wxPament;
        $openid = "o17JF0YnZCzw_NP3gdXyCxy55b6s";
        $wxPayRes = $wxPament->tixian(1, $openid, '佣金提现');
        if(!$wxPayRes || !isset($wxPayRes['payment_no'])){
            var_dump($wxPayRes);exit();
            throw new Exception('系统维护中');
        }
        echo "success";
    }

    //领取红包接口
    public function getRedPacket(){
        $param = $this->request->post();

        if(!is_numeric($param['money'])||strpos($param['money'],".")!==false){
            return Tools::buildReturn(ReturnCode::INVALID,'提现金额必须是整数');
        }
        if(!isset($param['openid'])) return Tools::buildReturn(ReturnCode::INVALID,'微信openid不能为空');
        if(!isset($param['cashID'])) return Tools::buildReturn(ReturnCode::INVALID,'提现ID不能为空');
        $amount = intval($param['money']);

        $cash = UserDeposit::get(['depositID' => $param['cashID']]);
        if(!isset($cash['depositID']))
            return Tools::buildReturn(ReturnCode::INVALID,'提现记录不存在');
        if($cash['status'] != 0){
            return Tools::buildReturn(ReturnCode::INVALID,'已经提现或者提现失败');
        }

        Db::startTrans();
        try{


            $userData = \app\model\User::get(['userID' => $cash['userID']]);
            if($userData['money'] < $cash['money']){
                throw new \Exception('余额不足');
            }

            if($amount != $cash['money'])    throw new \Exception('金额不一致');




            $flag = Db::name('user')->where(['userID' => $cash['userID']])
                ->update(['money' => Tools::bcCalculate($userData['money'], $amount, '-') * 100]);
            if(!$flag) throw new Exception('提现失败');

            $logModel = new \app\model\UserMoneyLog();
            $flag = $logModel->create([
                'userID' => $cash['userID'],
                'amount' => $amount,
                'balance' => Tools::bcCalculate($userData['money'], $amount, '-'),
                'ordertype' => 4,
                'turnover' => -1,
                'content' => '用户提现'.$amount.'元',
                'relateID' => $param['cashID'],
            ]);
            if(!$flag) throw new Exception('插入日志流水失败');

            $flag = Db::name('user_deposit')->where(['depositID' => $param['cashID']])
                ->update(['status' => 1]);
            if(!$flag)  throw new Exception('更新提现记录失败!');

            $wxPament = new wxPament;
            $wxPayRes = $wxPament->tixian($cash['money'], $param['openid'], '佣金提现');
            if(!$wxPayRes || !isset($wxPayRes['payment_no'])){
                throw new Exception('系统维护中');
            }

            Db::commit();
            return Tools::buildReturn(ReturnCode::SUCCESS,'提现成功');

        }catch (\Exception $e){
            Db::rollback();
            //tixian fail

            return Tools::buildReturn(ReturnCode::INVALID, $e->getMessage());
        }

    }

    //首页接口
    public function indexData(){
        $param = $this->request->post();
        $page = $this->request->post('page', 1);//当前页数
        $size = $this->request->post('size', config('apiAdmin.ADMIN_LIST_DEFAULT'));//每页显示数量
        $banner = Db::name('banner')->field('bannerID, title, thumb,link')->where(['status' => 1, 'place' => 1])->order('sort asc')->select();
        $where = ['status' => 1, 'isUp' => 1];
        if(isset($param['keyword']) && !empty($param['keyword']))
            $where['title'] = ['like', "%{$param['keyword']}%"];
        $task = Db::name('task')->field('taskID, title, logo,rewardName, rewardMoney, label, addTime,num, completeNUm, yuguMoney')
            ->where($where)
            ->limit(($page-1)*$size, $size)
            ->order('sort desc')
            ->select();
        $total = Db::name('task')->where($where)->count();
        $task_refer  = Db::name('task')->field('taskID, title, logo,rewardName, rewardMoney, label, addTime, num, completeNUm, yuguMoney')->where(['status' => 1, 'isUp' => 1])->order('sort asc')->find();
        foreach ($task as &$item){
            $item['addTime'] = date('Y-m-d H:i:s', $item['addTime']);
            $item['yuguMoney'] = Tools::bcCalculate($item['yuguMoney'], 100, '/');
            $item['rewardMoney'] = Tools::bcCalculate($item['rewardMoney'], 100, '/');
        }
        $task_refer['addTime'] = date('Y-m-d H:i:s', $task_refer['addTime']);
        $task_refer['rewardMoney'] = Tools::bcCalculate($task_refer['rewardMoney'], 100, '/');
        $task_refer['yuguMoney'] = Tools::bcCalculate($task_refer['yuguMoney'], 100, '/');
        return $this->buildSuccess(['task_list' => $task,'count' => $total, 'banner' => $banner, 'task_refer' => $task_refer], '操作成功');
    }

    public function getUserInit(){

        $user = Db::name('user')->where('userID', $this->userInfo['userID'])->find();
        $platform = Db::name('platform')->where('id', $user['platformID'])->find();
        $this->buildSuccess(['userText' => $platform['userText'], 'ysText' => $platform['ysText']], '操作成功');
    }


}
